package api

import (
	"context"

	"dev.ixmxm.top/rms/codes"
)

// @Summary 获取待命点信息
// @Description
// @Accept application/json
// @Produce application/json
// @Success 0 {object} ResponseExampleStruct "返回数据格式"
// @Success 1 {object} model.StandbySite "data数据：待命点信息"
// @Tags 待命点
// @Router /standby/get_standby_site [get]
func (hg *HttpGateway) GetStandbySite(ctx context.Context, params interface{}) (interface{}, codes.Code) {
	p := params.(*GetStandbySiteParams)
	site, err := hg.dispatcher.TRM().GetStandbySite(ctx, p.MapName, p.SiteId)
	if err != nil {
		return nil, err
	}
	//return gin.H{"list": sites}, nil
	return site, nil
}

// @Summary 获取所有待命点信息
// @Description
// @Accept application/json
// @Produce application/json
// @Success 0 {object} ResponseExampleList "返回数据格式"
// @Success 1 {object} []model.StandbySite "data数据：待命点信息集合"
// @Tags 待命点
// @Router /standby/get_standby_sites [get]
func (hg *HttpGateway) GetStandbySites(ctx context.Context, params interface{}) (interface{}, codes.Code) {
	sites, err := hg.dispatcher.TRM().GetStandbySites(ctx)
	if err != nil {
		return nil, err
	}
	//return gin.H{"list": sites}, nil
	return sites, nil
}

// @Summary 保存待命点禁用AGV列表
// @Description
// @Accept application/json
// @Produce application/json
// @Param body body saveStandbySiteParams true "保存待命点配置"
// @Success 0 {object} ResponseExample "返回数据格式"
// @Tags 待命点
// @Router /standby/save_standby_site [post]
func (hg *HttpGateway) SaveStandbySite(ctx context.Context, params interface{}) (interface{}, codes.Code) {
	p := params.(*saveStandbySiteParams)
	return nil, hg.dispatcher.TRM().SaveStandbySiteAboutBandAgvListToDB(ctx, p.MapName, p.SiteId, p.BanAgvList)
}

// @Summary 保存待命点允许分组集合
// @Description
// @Accept application/json
// @Produce application/json
// @Param body body saveStandbySiteGroupListParams true "保存待命点配置"
// @Success 0 {object} ResponseExample "返回数据格式"
// @Tags 待命点
// @Router /standby/save_standby_site_group_list [post]
func (hg *HttpGateway) SaveStandGroupListbySite(ctx context.Context, params interface{}) (interface{}, codes.Code) {
	p := params.(*saveStandbySiteGroupListParams)
	return nil, hg.dispatcher.TRM().SaveStandbySiteGroupListToDB(ctx, p.MapName, p.SiteId, p.AllowGroupList)
}
